package com.example.progressbartext;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.WindowManager;

/**
 * Created by Jawor
 * Time: 2018/5/7
 */

public class Loading_view extends ProgressDialog {
    public Loading_view(Context context) {
        super(context);
    }
    //传入主题样式
    public Loading_view(Context context, int theme) {
        super(context, theme);
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init(getContext());//初始化
    }
    private void init(Context context) {
        setCancelable(true);//设置是否可以返回键取消
        setCanceledOnTouchOutside(false);//设置是否可以点击外部取消
        setContentView(R.layout.loading);//loading的xml文件
        WindowManager.LayoutParams params = getWindow().getAttributes();//获取属性设置参数
        params.width = WindowManager.LayoutParams.WRAP_CONTENT;//设置宽
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(params);//把设置好的参数放置
    }
    @Override
    public void show() {//开启
        super.show();
    }
    @Override
    public void dismiss() {//关闭
        super.dismiss();
    }
}